#pragma once
#include <memory>
#include "wOHandle.hpp"
#include <vector>

namespace witotk{

template<class T>
class wCollection
{
public:
	typedef typename T::OHandle_type  T_OHandle_type ;
	typedef	std::tr1::shared_ptr<T> Item_ptr;
public:
	wCollection()
	{
	}

	wCollection(const std::vector<T_OHandle_type> &vec)
	{
		for(vector<T_OHandle_type>::const_iterator it = vec.begin(); it != vec.end(); it++)
		{
			T_OHandle_type aa = (*it);
			Item_ptr data(new T(aa));
			m_data.push_back(data);
		}
	}
	inline size_t size()
	{
		return m_data.size();
	}

	void push_back(const Item_ptr& item )
	{
		m_data.push_back(item);
	}

	Item_ptr operator[](size_t i)
	{
		return m_data[i];
	}

private:
	std::vector<Item_ptr> m_data;
};

template<class wCollection_T>
class wCollectionshared_ptr:public std::tr1::shared_ptr<wCollection_T>
{
	typedef std::tr1::shared_ptr<wCollection_T> base;
	typedef typename wCollection_T::Item_ptr Item_ptr;
public:
	Item_ptr operator[](size_t i)
	{
		wCollection_T * t = this->get();
		return t->operator[](i);
	}
	wCollectionshared_ptr(wCollection_T * p):base(p){}
	wCollectionshared_ptr():base(){}
};


}